﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using TrainingWorkshop.Contracts;
using TrainingWorkshop.DAL_EF;
using TrainingWorkshop.Models;

namespace TrainingWorkshop.Services
{
    [ServiceBehavior(Name = "ProjectBService")]
    public class ProjectBService:IProjectBService
    {
        EFFactory efFactory = new EFFactory();
        /// <summary>
        /// Get All Courses from database 
        /// </summary>
        /// <returns>List of CourseShows</returns>
        public List<Models.CourseShows> GetAllCourses()
        {
            ICourseRepository_EF iCourseRepository = efFactory.CourseRepository();
            List<CourseShows> courseShowsList = iCourseRepository.GetAllCourses();
            return courseShowsList;
        }

        /// <summary>
        /// Inherit from ICourse to Get Selected Courses
        /// </summary>
        /// <param name="courseName">string CourseName</param>
        /// <param name="courseStatus">bool CourseStatus</param>
        /// <returns>List of CourseShows</returns>
        public List<Models.CourseShows> GetAllSelectedCourses(string courseName, bool courseStatus)
        {
            ICourseRepository_EF iCourseRepository = efFactory.CourseRepository();
            List<CourseShows> courseShowsList = iCourseRepository.GetAllSelectedCourses(courseName, courseStatus);
            return courseShowsList;
        }

        /// <summary>
        /// Inherit from ICourse to Update Course
        /// </summary>
        /// <param name="course">Course Object</param>
        public void UpdateCourse(Models.Course course)
        {
            ICourseRepository_EF iCourseRepository = efFactory.CourseRepository();
            iCourseRepository.UpdateCourse(course);
        }

        /// <summary>
        /// Inherit from ICourse to Delete Course
        /// </summary>
        /// <param name="courseId">int CourseId</param>
        public void DeleteCourse(int courseId)
        {
            ICourseRepository_EF iCourseRepository = efFactory.CourseRepository();
            iCourseRepository.DeleteCourse(courseId);
        }

        /// <summary>
        /// Inherit from ICourse to Change CourseStatus
        /// </summary>
        /// <param name="course">Course Object</param>
        public void ChangeState(Models.Course course)
        {
            ICourseRepository_EF iCourseRepository = efFactory.CourseRepository();
            iCourseRepository.ChangeState(course);
        }

        /// <summary>
        /// Inherit from ILevel to Get all Levels from database
        /// </summary>
        /// <returns>List of Level</returns>
        public List<Models.Level> GetAllLevels()
        {
            ILevelRepository_EF iLevelRepository = efFactory.LevelRepository();
            return iLevelRepository.GetAllLevels();
        }
        /// <summary>
        /// Inherit from ITeacher to Get all Teachers from database
        /// </summary>
        /// <returns>List of Teacher</returns>
        public List<Models.Teacher> GetAllTeachers()
        {
            ITeacherRepository_EF iTeacherRepository = efFactory.TeacherRepository();
            return iTeacherRepository.GetAllTeachers();
        }
    }
}
